package com.hello.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.hello.dao.Sdao;
import com.hello.domain.User;

@Controller
@RequestMapping("/listAllUsers.html")
@SessionAttributes("user")
public class ListUserController {
	
	private Sdao dao;

	@RequestMapping(method = RequestMethod.GET)
	public String showListForm(ModelMap model) {
		User user = this.getDao().findUserByName("lamusicoscos");
		List<User> userLists = getDao().findAllUsers();
		model.addAttribute(user);
		model.addAttribute("users", userLists);
		return "listForm";
	}

	@Autowired
	public void setDao(Sdao dao) {
		this.dao = dao;
	}

	public Sdao getDao() {
		return dao;
	}
}
